<template>
	<view>
		<web-view :src="pdfUrl"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				pdfUrl:'',
				from:'',
				list: [
					{
						
					},
					{
						name: '邢台支队基层党务工作常见问题300问',
					},
					{
						name: '邢台支队基层党组织标准化规范化建设文书及流程图手册', 
					},
					{
						name: '邢台支队基层组织标准化规范化建设手册',
					},
					{
						name: '邢台支队正规化建设图册',
					},
					{
						name: '邢台支队正规化资料汇编',
					},
					{
						name: '正规化建设汇报材料',
					},
					{
						name: '支队正规化现场会经验汇报',
					}
				],
				index:null,
			}
		},
		onReady() {
			let that=this;
			uni.setNavigationBarTitle({
				 title: that.list[that.index].name,
				 success(e) {
					 console.log(that.list[that.index].name)
				 	 console.log(e)
				 },
				 fail(e){
					 console.log(e)
				 }
			})
		},
		onShow() {
			let that=this;
			uni.setNavigationBarTitle({
				 title: that.list[that.index].name,
				 success(e) {
					 console.log(that.list[that.index].name)
				 	 console.log(e)
				 },
				 fail(e){
					 console.log(e)
				 }
			})
		},
		onLoad(data) {
			let that=this;
			that.index=parseFloat(data.index);
			console.log(parseFloat(data.index))
		
			/**
			 * 浏览情景
			 */
			// 浏览情景1:浏览本地的pdf文件
			 //this.pdfUrl = '/hybrid/html/web/viewer.html?file=./'+data.index+'.pdf'
			// 浏览情景2:浏览在线的pdf文件
			this.pdfUrl = '/hybrid/html/web/viewer.html?file='+encodeURIComponent('http://oss.91xiaokong.com/fireControl/pdf/'+data.index+'.pdf')
		},
		methods: {
			/**
			 * 下载情景
			 */
			downloadPdfClick(){
				// 下载情景1:h5内嵌app,通过分享给朋友的方式进行下载
				if(this.from == 'app'){
					let item = 'http://自己的域名/hybrid/html/web/pdf.html?shareUrl='+encodeURIComponent(this.bgUrl)
								+'&shareTitle=PDF文件';
					window.open(item);
					return;
					
				}else if(this.from == 'wx wq'){
				// 下载情景2:h5内嵌微信小程序,从h5页面跳转到小程序页面后,然后通过调用小程序原生API进行下载
				// 注意: 先要引入微信jssdk  [命令: npm install jweixin-module]
					// this.$wx.miniProgram.navigateTo({
					// 	url: '/pages/pdf/pdf_download?pdf='+ encodeURIComponent(this.bgUrl) //小程序页面链接
					// });
				}
				
			}
		}
	}
</script>

<style>

</style>
